##############################################################
#Figure C8: Risk Aversion by Zipcode
##############################################################

risk_data <- read.dta13("./input/cces-sub.dta")
data(zipcode)
risk_data$zip<- clean.zipcodes(risk_data$zipcode)
result <- merge(risk_data, zipcode, by="zip")
head(result)

states_map <- map_data("state")

ggplot(result,aes(longitude,latitude)) +
  geom_polygon(data=states_map,aes(x=long,y=lat,group=group),color='grey',fill=NA,alpha=.35)+
  geom_point(aes(color = risk),size=2,alpha=.25) +
  theme(panel.background = element_blank(),
        axis.line = element_blank(),
        axis.title = element_blank(),
        axis.text=element_blank(),
        axis.ticks = element_blank()) + 
  xlim(-125,-65)+ylim(20,50) +
  scale_color_continuous(low="skyblue", high="darkblue", na.value="black", name="Risk Aversion Level")
ggsave("./figures/figc8.pdf")
